
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>04-Thrift代码生成 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="thrift-05-architecture.html" />
    
    
    <link rel="prev" href="thrift-03-types.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../">
            
                <a href="../../">
            
                    
                    编辑器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../editortools/SublineText3-Quick-Key.html">
            
                <a href="../../editortools/SublineText3-Quick-Key.html">
            
                    
                    SublineText3快捷键
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../editortools/SublineText3.html">
            
                <a href="../../editortools/SublineText3.html">
            
                    
                    SublineText3问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../editortools/iTerm2-guide.html">
            
                <a href="../../editortools/iTerm2-guide.html">
            
                    
                    iTerm2指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../">
            
                <a href="../../">
            
                    
                    乱七八糟
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../sundry/git-note.html">
            
                <a href="../../sundry/git-note.html">
            
                    
                    Git 简单笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../sundry/gitbook-doc.html">
            
                <a href="../../sundry/gitbook-doc.html">
            
                    
                    gitbook 教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../sundry/gitbook-to-github.html">
            
                <a href="../../sundry/gitbook-to-github.html">
            
                    
                    gitbook 集成到Github
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../../sundry/git-integrate.html">
            
                <a href="../../sundry/git-integrate.html">
            
                    
                    Git提速
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../../sundry/markdown-doc.html">
            
                <a href="../../sundry/markdown-doc.html">
            
                    
                    markdown 语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../../sundry/maven-nexus.html">
            
                <a href="../../sundry/maven-nexus.html">
            
                    
                    Maven 私服搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../../sundry/idea-config.html">
            
                <a href="../../sundry/idea-config.html">
            
                    
                    IDEA 配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../../sundry/idea-quick-key.html">
            
                <a href="../../sundry/idea-quick-key.html">
            
                    
                    IDEA 快捷键
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../../sundry/iterm2.html">
            
                <a href="../../sundry/iterm2.html">
            
                    
                    iTerm2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" >
            
                <a target="_blank" href="http://fontawesome.dashgame.com/">
            
                    
                    Font Awesome字体
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../">
            
                <a href="../../">
            
                    
                    mariadb
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../mariadb/mariadb-install.html">
            
                <a href="../../mariadb/mariadb-install.html">
            
                    
                    mariadb 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../../mariadb/mysql-install.html">
            
                <a href="../../mariadb/mysql-install.html">
            
                    
                    mysql 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../../mariadb/mysql-base.html">
            
                <a href="../../mariadb/mysql-base.html">
            
                    
                    mysql 基础知识
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../">
            
                <a href="../../">
            
                    
                    MongoDB
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../../mongodb/mongodb-install.html">
            
                <a href="../../mongodb/mongodb-install.html">
            
                    
                    MongoDB 安装
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../../">
            
                <a href="../../">
            
                    
                    nginx
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../../nginx/nginx-install.html">
            
                <a href="../../nginx/nginx-install.html">
            
                    
                    Nginx 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../../nginx/nginx-commandline.html">
            
                <a href="../../nginx/nginx-commandline.html">
            
                    
                    Ngixn 命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../../nginx/nginx-virtualhost.html">
            
                <a href="../../nginx/nginx-virtualhost.html">
            
                    
                    Nginx 虚拟主机
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../../">
            
                <a href="../../">
            
                    
                    HttpClient
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../../httpclient/httpclient-timeout.html">
            
                <a href="../../httpclient/httpclient-timeout.html">
            
                    
                    HttpClient几个超时
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../../httpclient/httpclient-pool.html">
            
                <a href="../../httpclient/httpclient-pool.html">
            
                    
                    HttpClient 连接池
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../../">
            
                <a href="../../">
            
                    
                    Java
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../../java/001-tomcat-loader-cpu-high.html">
            
                <a href="../../java/001-tomcat-loader-cpu-high.html">
            
                    
                    01-Tomcat应用负载过高—CPU过高
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../../">
            
                <a href="../../">
            
                    
                    Spring与SpringBoot
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../../SpringBoot/001-SpringBoot-form-jar-to-war.html">
            
                <a href="../../SpringBoot/001-SpringBoot-form-jar-to-war.html">
            
                    
                    01-SpringBoot-Jar包转war包
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../../">
            
                <a href="../../">
            
                    
                    RPC
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="thrift-01-intro.html">
            
                <a href="thrift-01-intro.html">
            
                    
                    01-Thrift简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="thrift-02-install.html">
            
                <a href="thrift-02-install.html">
            
                    
                    02-Thrift安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="thrift-03-types.html">
            
                <a href="thrift-03-types.html">
            
                    
                    03-Thrift数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.10.4" data-path="thrift-04-generated-code.html">
            
                <a href="thrift-04-generated-code.html">
            
                    
                    04-Thrift代码生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="thrift-05-architecture.html">
            
                <a href="thrift-05-architecture.html">
            
                    
                    05-Thrift架构设计
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../../">
            
                <a href="../../">
            
                    
                    线程世界
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../../thread/01-traditional-thread.html">
            
                <a href="../../thread/01-traditional-thread.html">
            
                    
                    01-传统线程技术
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../../thread/02-traditional-mutex.html">
            
                <a href="../../thread/02-traditional-mutex.html">
            
                    
                    02-线程之间的互斥
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../../thread/03-traditional-communication.html">
            
                <a href="../../thread/03-traditional-communication.html">
            
                    
                    03-线程之间的通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../../thread/04-traditional-thread-state.html">
            
                <a href="../../thread/04-traditional-thread-state.html">
            
                    
                    04-线程状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../../thread/05-traditional-thread-join.html">
            
                <a href="../../thread/05-traditional-thread-join.html">
            
                    
                    05-线程join方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../../">
            
                <a href="../../">
            
                    
                    Linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../../linux/001-linux-command.html">
            
                <a href="../../linux/001-linux-command.html">
            
                    
                    01-Linux常用命令总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../../linux/002-linux-firewall.html">
            
                <a href="../../linux/002-linux-firewall.html">
            
                    
                    02-Linux防火墙
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../../linux/003-linux-tmux.html">
            
                <a href="../../linux/003-linux-tmux.html">
            
                    
                    03-Linux-Tmux
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../../">
            
                <a href="../../">
            
                    
                    数据结构与算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../../datastructure/01-intro.html">
            
                <a href="../../datastructure/01-intro.html">
            
                    
                    01-简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../../">
            
                <a href="../../">
            
                    
                    前端
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../../front/01-yarn.html">
            
                <a href="../../front/01-yarn.html">
            
                    
                    01-yarn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../../front/02-jsx.html">
            
                <a href="../../front/02-jsx.html">
            
                    
                    02-jsx语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../../front/03-react-component.html">
            
                <a href="../../front/03-react-component.html">
            
                    
                    03-React组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.4" data-path="../../front/04-ES6.html">
            
                <a href="../../front/04-ES6.html">
            
                    
                    04-ES6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.5" data-path="../../front/05-webpack.html">
            
                <a href="../../front/05-webpack.html">
            
                    
                    05-webpack
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >04-Thrift代码生成</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4EE3;&#x7801;&#x751F;&#x6210;">&#x4EE3;&#x7801;&#x751F;&#x6210;</h1>
<h3 id="1-&#x57FA;&#x672C;&#x6982;&#x5FF5;">1 &#x57FA;&#x672C;&#x6982;&#x5FF5;</h3>
<p>&#x5148;&#x770B;&#x4E0B;&#x56FE;&#xFF0C;<code>Thrift</code> &#x7F51;&#x7EDC;&#x67B6;&#x6784;&#x3002;<br><img src="../images/thrift-network-stack.jpg" alt="thrift network stack"></p>
<h4 id="11-transport-&#xFF08;&#x4F20;&#x8F93;&#x5C42;&#xFF09;">1.1 Transport &#xFF08;&#x4F20;&#x8F93;&#x5C42;&#xFF09;</h4>
<p>&#x4F20;&#x8F93;&#x5C42;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x7B80;&#x5355;&#x62BD;&#x8C61;&#x7684;&#x4ECE;&#x7F51;&#x7EDC;&#x4E2D;&#x8BFB;&#x5199;&#x7684;&#x63A5;&#x53E3;&#xFF0C;&#x8FD9;&#x4F7F; <code>Thrift</code> &#x80FD;&#x591F;&#x5C06;&#x5E95;&#x5C42;&#x4F20;&#x8F93;&#x4E0E;&#x7CFB;&#x7EDF;&#x7684;&#x5176;&#x4F59;&#x90E8;&#x5206;&#x5206;&#x79BB;&#xFF08;&#x4F8B;&#x5982;&#xFF0C;&#x5E8F;&#x5217;&#x5316;/&#x53CD;&#x5E8F;&#x5217;&#x5316;&#xFF09;&#x3002;</p>
<p>&#x4F20;&#x8F93;&#x5C42;&#x66B4;&#x9732;&#x7684;&#x63A5;&#x53E3;&#x6709;&#xFF1A;</p>
<ul>
<li>open</li>
<li>close</li>
<li>read</li>
<li>write</li>
<li>flush</li>
</ul>
<p>&#x9664;&#x4E86;&#x4E0A;&#x9762;&#x7684; <code>Transport</code> &#x63A5;&#x53E3;&#x4E4B;&#x5916;&#xFF0C;<code>Thrift</code> &#x8FD8;&#x4F7F;&#x7528; <code>ServerTransport</code> &#x63A5;&#x53E3;&#x6765;&#x63A5;&#x6536;&#x6216;&#x521B;&#x5EFA;&#x539F;&#x59CB;&#x4F20;&#x8F93;&#x5BF9;&#x8C61;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;<code>ServerTransport</code> &#x4E3B;&#x8981;&#x7528;&#x4E8E;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#xFF0C;&#x4E3A;&#x4F20;&#x5165;&#x8FDE;&#x63A5;&#x521B;&#x5EFA;&#x65B0;&#x7684;&#x4F20;&#x8F93;&#x5BF9;&#x8C61;&#x3002;<code>ServerTransport</code> &#x63A5;&#x53E3;&#x6709;&#xFF1A;</p>
<ul>
<li>listen</li>
<li>accept</li>
<li>close</li>
</ul>
<h4 id="12-&#x534F;&#x8BAE;&#xFF08;protocol&#xFF09;">1.2 &#x534F;&#x8BAE;&#xFF08;Protocol&#xFF09;</h4>
<p>&#x534F;&#x8BAE;&#x62BD;&#x8C61;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x79CD;&#x5C06;&#x5185;&#x5B58;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x6620;&#x5C04;&#x6210;&#x7EBF;&#x6027;&#x683C;&#x5F0F;&#x7684;&#x673A;&#x5236;&#xFF0C;&#x6362;&#x53E5;&#x8BDD;&#x8BF4;&#xFF0C;&#x534F;&#x8BAE;&#x6307;&#x5B9A;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x5E95;&#x5C42;&#x4F20;&#x8F93;&#x8FDB;&#x884C;&#x7F16;&#x7801;/&#x89E3;&#x7801;&#x3002;&#x56E0;&#x6B64;&#x534F;&#x8BAE;&#x7684;&#x5B9E;&#x73B0;&#x63A7;&#x5236;&#x7F16;&#x7801;&#x65B9;&#x6848;&#x5E76;&#x8D1F;&#x8D23;&#x5E8F;&#x5217;&#x5316;&#x548C;&#x53CD;&#x5E8F;&#x5217;&#x5316;&#xFF0C;<code>Thrift</code> &#x63D0;&#x4F9B;&#x7684;&#x7C7B;&#x4F3C;&#x534F;&#x8BAE;&#x6709;&#x57FA;&#x4E8E; <code>JSON</code>&#x3001;<code>XML</code>&#x3001;<code>plain text</code>&#x3001;<code>compact binary</code> &#x7B49;&#x3002;</p>
<p>&#x534F;&#x8BAE;&#x7684;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;&#x6709;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-thrift">writeMessageBegin(name, type, seq)
writeMessageEnd()
writeStructBegin(name)
writeStructEnd()
writeFieldBegin(name, type, id)
writeFieldEnd()
writeFieldStop()
writeMapBegin(ktype, vtype, size)
writeMapEnd()
writeListBegin(etype, size)
writeListEnd()
writeSetBegin(etype, size)
writeSetEnd()
writeBool(<span class="hljs-built_in">bool</span>)
writeByte(<span class="hljs-built_in">byte</span>)
writeI16(<span class="hljs-built_in">i16</span>)
writeI32(<span class="hljs-built_in">i32</span>)
writeI64(<span class="hljs-built_in">i64</span>)
writeDouble(<span class="hljs-built_in">double</span>)
writeString(<span class="hljs-built_in">string</span>)

name, type, seq = readMessageBegin()
readMessageEnd()
name = readStructBegin()
readStructEnd()
name, type, id = readFieldBegin()
readFieldEnd()
k, v, size = readMapBegin()
readMapEnd()
etype, size = readListBegin()
readListEnd()
etype, size = readSetBegin()
readSetEnd()
<span class="hljs-built_in">bool</span> = readBool()
<span class="hljs-built_in">byte</span> = readByte()
<span class="hljs-built_in">i16</span> = readI16()
<span class="hljs-built_in">i32</span> = readI32()
<span class="hljs-built_in">i64</span> = readI64()
<span class="hljs-built_in">double</span> = readDouble()
<span class="hljs-built_in">string</span> = readString()
</code></pre>
<p><code>Thrift</code> &#x534F;&#x8BAE;&#x662F;&#x4EE5;&#x6D41;&#x7684;&#x5F62;&#x5F0F;&#x8BBE;&#x8BA1;&#x7684;&#xFF0C;&#x56E0;&#x6B64;&#x4E0D;&#x9700;&#x8981;&#x4EFB;&#x4F55;&#x660E;&#x786E;&#x7684;&#x6846;&#x67B6;&#xFF0C;&#x4F8B;&#x5982;&#xFF0C;&#x5728;&#x5F00;&#x59CB;&#x5E8F;&#x5217;&#x5316;&#x4E4B;&#x524D;&#xFF0C;&#x65E0;&#x9700;&#x77E5;&#x9053;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x957F;&#x5EA6;&#x6216;&#x8005;&#x5217;&#x8868;&#x4E2D;&#x5143;&#x7D20;&#x7684;&#x6570;&#x76EE;&#x3002;</p>
<p>&#x4EE5;&#x4E0B;&#x662F; <code>Thrift</code> &#x652F;&#x6301;&#x7684;&#x5927;&#x591A;&#x6570;&#x8BED;&#x8A00;&#x53EF;&#x7528;&#x7684;&#x4E00;&#x4E9B;&#x534F;&#x8BAE;&#xFF1A;</p>
<ul>
<li>binary &#x7B80;&#x5355;&#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x7F16;&#x7801;&#xFF0C;&#x7F16;&#x7801;&#x4E3A;&#x4E8C;&#x8FDB;&#x5236;&#x65F6;&#x662F;&#xFF0C;&#x5B57;&#x6BB5;&#x7684;&#x957F;&#x5EA6;&#xFF0C;&#x5B57;&#x6BB5;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x5B57;&#x6BB5;&#x7684;&#x503C;</li>
<li>compact &#x538B;&#x7F29;&#x7684;&#x4E8C;&#x8FDB;&#x5236;</li>
<li>json  JSON &#x683C;&#x5F0F;</li>
</ul>
<h4 id="13-&#x5904;&#x7406;&#x5668;&#xFF08;processor&#xFF09;">1.3 &#x5904;&#x7406;&#x5668;&#xFF08;Processor&#xFF09;</h4>
<p>&#x5904;&#x7406;&#x5668;&#x5C01;&#x88C5;&#x4E86;&#x4ECE;&#x8F93;&#x5165;&#x6D41;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x548C;&#x5199;&#x5165;&#x6570;&#x636E;&#x5230;&#x8F93;&#x51FA;&#x6D41;&#x7684;&#x80FD;&#x529B;&#xFF0C;&#x8F93;&#x5165;&#x548C;&#x8F93;&#x51FA;&#x6D41;&#x5747;&#x662F;&#x7531;&#x534F;&#x8BAE;(Protocol)&#x5BF9;&#x8C61;&#x8868;&#x793A;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x5904;&#x7406;&#x5668;&#x63A5;&#x53E3;&#x5F02;&#x5E38;&#x7684;&#x7B80;&#x5355;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">TProcessor</span> </span>{
    <span class="hljs-function">bool <span class="hljs-title">process</span><span class="hljs-params">(TProtocol in, TProtocol out)</span> <span class="hljs-keyword">throws</span> TException
}
</span></code></pre>
<p>&#x7279;&#x5B9A;&#x4E8E;&#x670D;&#x52A1;&#x7684;&#x5904;&#x7406;&#x5668;&#x662F;&#x7531;&#x7F16;&#x8BD1;&#x5668;&#x751F;&#x6210;&#x7684;&#xFF0C;&#x5904;&#x7406;&#x5668;&#x4E00;&#x822C;&#x662F;&#x4ECE;&#x7F51;&#x7EDC;&#x4E2D;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#xFF08;&#x4F7F;&#x7528;&#x8F93;&#x5165;&#x534F;&#x8BAE;&#xFF09;&#xFF0C;&#x5C06;&#x5904;&#x7406;&#x59D4;&#x6258;&#x7ED9;&#x5904;&#x7406;&#x7A0B;&#x5E8F;&#xFF08;&#x7531;&#x7528;&#x6237;&#x5B9E;&#x73B0;&#xFF09;&#xFF0C;&#x7136;&#x540E;&#x5C06;&#x5904;&#x7406;&#x7ED3;&#x679C;&#x901A;&#x8FC7;&#x7F51;&#x7EDC;&#x4F20;&#x9012;&#x7ED9;&#x5BA2;&#x6237;&#x7AEF;&#xFF08;&#x4F7F;&#x7528;&#x8F93;&#x51FA;&#x534F;&#x8BAE;&#xFF09;&#x3002;</p>
<h4 id="14-&#x670D;&#x52A1;&#x5668;">1.4 &#x670D;&#x52A1;&#x5668;</h4>
<p>&#x670D;&#x52A1;&#x5668;&#x6C47;&#x805A;&#x4E86;&#x4EE5;&#x4E0A;&#x5404;&#x79CD;&#x529F;&#x80FD;&#xFF1A;</p>
<ul>
<li>&#x521B;&#x5EFA;&#x4F20;&#x8F93;&#x5C42;&#xFF08;Transport&#xFF09;</li>
<li>&#x4E3A;&#x4F20;&#x8F93;&#x5C42;&#x521B;&#x5EFA;&#x8F93;&#x5165;/&#x8F93;&#x51FA;&#x534F;&#x8BAE;</li>
<li>&#x57FA;&#x4E8E;&#x8F93;&#x5165;/&#x8F93;&#x51FA;&#x534F;&#x8BAE;&#x521B;&#x5EFA;&#x5904;&#x7406;&#x5668;</li>
<li>&#x7B49;&#x5F85;&#x4F20;&#x5165;&#x8FDE;&#x63A5;&#x5E76;&#x5C06;&#x5176;&#x4EA4;&#x7ED9;&#x5904;&#x7406;&#x5668;</li>
</ul>
<h3 id="2-&#x6700;&#x4F73;&#x5B9E;&#x8DF5;">2. &#x6700;&#x4F73;&#x5B9E;&#x8DF5;</h3>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="thrift-03-types.html" class="navigation navigation-prev " aria-label="Previous page: 03-Thrift数据类型">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="thrift-05-architecture.html" class="navigation navigation-next " aria-label="Next page: 05-Thrift架构设计">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"04-Thrift代码生成","level":"1.10.4","depth":2,"next":{"title":"05-Thrift架构设计","level":"1.10.5","depth":2,"path":"rpc/thrift/thrift-05-architecture.md","ref":"rpc/thrift/thrift-05-architecture.md","articles":[]},"previous":{"title":"03-Thrift数据类型","level":"1.10.3","depth":2,"path":"rpc/thrift/thrift-03-types.md","ref":"rpc/thrift/thrift-03-types.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["toggle-chapters"],"pluginsConfig":{"toggle-chapters":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"rpc/thrift/thrift-04-generated-code.md","mtime":"2019-09-08T13:54:11.881Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-17T05:25:43.709Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

